package com.harry.threaddemo;

import java.util.concurrent.TimeUnit;

/**
 *
 * 一直运行的线程，中断状态为 true
 * 
 * @author Harry
 * @date 2018/3/22 11:28
 */
public class InterruptedThread implements Runnable {

	public static int i = 0;

	@Override
	public void run() {
		// 一直 run
		while (true) {
			i++;
			System.out.println("一直 run:i="+i);
		}
	}

	public static void main(String[] args) throws Exception {
		Thread interruptedThread = new Thread(new InterruptedThread(), "InterruptedThread");
		interruptedThread.start();

		TimeUnit.SECONDS.sleep(2);

		interruptedThread.interrupt();
		System.out.println("InterruptedThread interrupted is " + interruptedThread.isInterrupted());

		TimeUnit.SECONDS.sleep(2);
	}
}
